//
//  main.m
//  OC6_字典&集合课后作业3省份
//
//  Created by dllo on 15/10/31.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
//#import "Area.h"
//#import "AreaManager.h"

int main(int argc, const char * argv[]) {

    NSString *filePath = @"/Users/dllo/Desktop/省市区/area.txt";
    NSString *str = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
//    NSLog(@"%@", str);
    

    NSArray *arr = [str componentsSeparatedByString:@"\n"];

//    NSLog(@"%@", arr);
    
    NSMutableArray *proArr = [[NSMutableArray alloc] init];             // 省数组
    NSMutableDictionary *proDic = [[NSMutableDictionary alloc] init];   // 省字典
    NSMutableArray *cityArr = [[NSMutableArray alloc] init];            // 省字典value = 市数组
    NSMutableDictionary *cityDic = [[NSMutableDictionary alloc] init];  // 市字典
    NSMutableArray *areaArr = [[NSMutableArray alloc] init];            // 市字典value = 区数组
    
    // 省
    for (NSInteger i = 0; i < arr.count; i++) {
        NSString *temp = [arr objectAtIndex:i];
        if ([[arr objectAtIndex:i] length ] < 7) {
            [proArr addObject:temp];
            [cityArr addObject:temp];
            [proDic setValue:cityArr forKey:temp];
            continue;
        }
        // 市
        if ([[arr objectAtIndex:i] hasPrefix:@"  "] && !([[arr objectAtIndex:i] hasPrefix:@"   "])) {
            [areaArr addObject:temp];
            [cityDic setObject:areaArr forKey:temp];
            continue;
        }
        // 区
        else{
            [areaArr addObject:temp];
        }
        
        
        
        
        
        
        
        
        
    }
    

    
    
    
    
    
    return 0;
}
